package com.kmist.xiakexing.main.socket;

public class DataSender {
    private String cmd;
    private String data;
    private int sendLength;

    public DataSender() {
    }

    public DataSender(String cmd){
        this.cmd = cmd;
        this.data = "0";
        this.sendLength = 0;
    }

    public DataSender(String cmd, String data) {
        this.cmd = cmd;
        this.data = data;
        this.sendLength = cmd.length() + data.length() + 3;
    }

    public String getCmd() {
        return cmd;
    }

    public void setCmd(String cmd) {
        this.cmd = cmd;
    }

    public int getSendLength() {
        return sendLength;
    }

    public void setSendLength(int sendLength) {
        this.sendLength = sendLength;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }


    @Override
    public String toString() {
        return "{" +
                "\"cmd\":\"" + cmd + "\"" +
                //",\"length\":" + (sendLength+1) +
                ", \"data\":" + data +
                '}';
    }
}
